<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Miniappsban extends Model
{
    protected $table = 'miniapps_ban';
    protected $primaryKey = 'id';

    public static function insertMiniappBanRecord($users_id,$appid,$appid_new,$mini_name,$mini_name_new,$visit_status)
    {
        return self::insert(["users_id"=>$users_id,"appid"=>$appid,"appid_new"=>$appid_new,"mini_name"=>$mini_name,"mini_name_new"=>$mini_name_new,"visit_status"=>$visit_status,"created_at"=>time()]);
    }

    public static function getSettingMiniappsNotice()
    {
        return self::select('users.nike','links_lists_minapps.name','setting_miniapps_notice.*')
                ->leftjoin('users', 'users.id', '=', 'setting_miniapps_notice.users_id')
                ->leftjoin('links_lists_minapps', 'links_lists_minapps.id', '=', 'setting_miniapps_notice.links_lists_minapps_id')
                ->orderBy("setting_miniapps_notice.id","DESC")
                ->orderBy('setting_miniapps_notice.links_lists_minapps_id', 'DESC')
                ->paginate(25);
    }
}
